﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NewEMail1.aspx.cs" Inherits="timer_NewEMail1" %>

<%@ Register Assembly="zoyobar.shared.panzer.JQueryElement" Namespace="zoyobar.shared.panzer.ui.jqueryui"
	TagPrefix="je" %>
<%@ Register Assembly="zoyobar.shared.panzer.JQueryElement" Namespace="zoyobar.shared.panzer.ui.jqueryui.plusin"
	TagPrefix="je" %>
<%@ Register Assembly="zoyobar.shared.panzer.JQueryElement" Namespace="zoyobar.shared.panzer.web.jqueryui"
	TagPrefix="je" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title>新邮件提醒</title>
	<link rel="stylesheet" type="text/css" href="../css/smoothness/jquery-ui-1.8.15.custom.css" />
	<script type="text/javascript" src="../js/jquery-1.6.2.min.js"></script>
	<script type="text/javascript" src="../js/jquery-ui-1.8.15.custom.min.js"></script>
	<link rel="stylesheet" type="text/css" href="../css/main.css" />
	<style type="text/css">
		#list
		{
			width: 100%;
		}
		thead
		{
			font-weight: bold;
		}
		.sender
		{
			color: Green;
		}
		.new-mail
		{
			font-weight: bold;
		}
		.timer
		{
			color: #666666;
		}
		#pageindex
		{
			color: #009900;
			width: 20px;
		}
	</style>
	<script type="text/javascript">
		function refreshSendButton(pe, e) {

			if (vSender.__validator('option', 'valid') && vTitle.__validator('option', 'valid'))
				cmdSend.button('enable');
			else
				cmdSend.button('disable');

		}

		var newEMailCount = 0;
	</script>
</head>
<body>
	<form id="formNewEMail1" runat="server">
	<div class="title green-title">
		新邮件提醒
		<iframe src="../about.htm" frameborder="0" height="160" width="100%" allowtransparency="true" scrolling="no"></iframe>
	</div>
	<div class="content">
		<h2>
			说明
		</h2>
		<blockquote>
			请确保已经阅读 <a href="../returnjson/Default.aspx">在不同的 .NET 版本中返回 JSON</a>. 本页代码中注册按钮的
			Success 事件符合 .NET 2.0 版本, 其它版本请另作调整.<br />
			<br />
			<strong>视频解说:</strong> <a href="http://www.tudou.com/programs/view/bGiJ5XUyfVI/" target="_blank">
				www.tudou.com/programs/view/bGiJ5XUyfVI/</a>
		</blockquote>
		<h2>
			示例
		</h2>
		<blockquote>
			<table id="list">
				<je:Repeater ID="emailRepeater" runat="server" IsVariable="true" Selector="'#list'"
					PageSize="4" FillAsync-Url="webservice.asmx" FillAsync-MethodName="GetEMailList">
					<HeaderTemplate>
						<thead>
							<tr>
								<td>
									发信人
								</td>
								<td>
									标题
								</td>
								<td>
									时间
								</td>
							</tr>
						</thead>
					</HeaderTemplate>
					<ItemTemplate>
						<tr>
							<td class="sender">
								#{sender}
							</td>
							<td class="#{isnew,# ? 'new-mail' : ''}">
								#{title}
							</td>
							<td class="timer">
								#{time,jQuery.panzer.formatDate(#,'yyyy-M-d')}
							</td>
						</tr>
					</ItemTemplate>
					<FooterTemplate>
						<tfoot>
							<tr>
								<td colspan="2">
									<a href="#" je-onclick="prev">上一页</a>&nbsp;&nbsp;<a href="#" je-onclick="next">下一页</a>,&nbsp;
									第 @{pageindex}/@{pagecount} 页, 共 @{itemcount} 条, <a href="#" je-onclick="goto,new Number(jQuery('#pageindex').val())">
										跳转</a> 到第
									<input type="text" id="pageindex" value="@{pageindex}" />
									页.
								</td>
							</tr>
						</tfoot>
					</FooterTemplate>
				</je:Repeater>
			</table>
			<je:Dialog ID="newDialog" runat="server" IsVariable="true" AutoOpen="false" Position="['right', 'bottom']"
				Html='您有 <strong id="newcount"></strong> 封新邮件' Buttons="{'刷新': function(){ emailRepeater.__repeater('filter'); newDialog.dialog('close'); }}" Close="function(){ newEMailCount = 0; }">
			</je:Dialog>
			<je:Timer ID="checkTimer" runat="server" IsVariable="true" Interval="5000">
				<TickAsync Url="webservice.asmx" MethodName="NewEMailCount" Success="
				function(data){
					// 如果是 .NET 3.5, 4.0 需要换成 data.d
					newEMailCount += data;

					if(newEMailCount != 0){
						$('#newcount').text(newEMailCount.toString());
						newDialog.dialog('open');
					}

				}
				">
				</TickAsync>
			</je:Timer>
			<hr />
			<strong>发信人:</strong>
			<input type="text" id="eSender" />
			<je:Validator ID="vSender" runat="server" IsVariable="true" Target="#eSender" Need="true"
				NeedTip='<font color="red">请填写发信人</font>' Reg="$.panzer.reg.email" RegTip='<font color="red">请填写一个正确的邮箱地址</font>'
				Checked="refreshSendButton">
			</je:Validator>
			<br />
			<br />
			<strong>标题:&nbsp;&nbsp;&nbsp;</strong>
			<input type="text" id="eTitle" />
			<je:Validator ID="vTitle" runat="server" IsVariable="true" Target="#eTitle" Need="true"
				NeedTip='<font color="red">请填写标题</font>' Checked="refreshSendButton">
			</je:Validator>
			<br />
			<br />
			<je:Button ID="cmdSend" runat="server" IsVariable="true" Label="发送" Disabled="true">
				<ClickAsync Url="webservice.asmx" MethodName="SendEMail" Success="
				function(data){
					alert(data);
				}
				">
					<ParameterList>
						<je:Parameter Name="sender" Type="Expression" Value="vSender.__validator('option','value')" />
						<je:Parameter Name="title" Type="Selector" Value="'#eTitle'" />
					</ParameterList>
				</ClickAsync>
			</je:Button>
		</blockquote>
	</div>
	</form>
</body>
</html>
<script type="text/javascript">
	$(function () {
		checkTimer.__timer('start');
		emailRepeater.__repeater('fill');
	});
</script>
